
class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}

public class Text {
    TreeNode pcur = null;
    public void inorder(TreeNode pRootOfTree){
        if(pRootOfTree == null){
            return;
        }
        inorder(pRootOfTree.left);
        pRootOfTree.left = pcur;
        if(pcur != null){
            pcur.right = pRootOfTree;
        }
        pcur = pRootOfTree;
        inorder(pRootOfTree.right);
    }
    public TreeNode Convert(TreeNode pRootOfTree) {
        if(pRootOfTree == null){
            return null;
        }
        inorder(pRootOfTree);
        while( pRootOfTree.left != null){
            pRootOfTree = pRootOfTree.left;
        }
        return pRootOfTree;
    }
}
